$(function() {
	queryAdminStatData();
})
function queryAdminStatData() {
	$.ajax({
		url : path + "/admin/stat/info",
		type : "get",
		dataType : "html",
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminSuggestList(pageNo) {
	var queryData = $("#admin_suggest_choose_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}
	$.ajax({
		url : path + "/admin/suggest/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminChannelGrayList(pageNo) {
	var queryData = $("#admin_channel_gray_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}
	$.ajax({
		url : path + "/admin/channelgray/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function auditChannelGray(channelGrayId, auditStatus) {
	$.ajax({
		url : path + "/admin/channelgray/audit",
		type : "post",
		dataType : "json",
		data : {
			channelGrayId : channelGrayId,
			auditStatus : auditStatus
		},
		success : function(data) {
			if (data.result) {
				layer.msg(data.message, {
					icon : 1
				});
				queryAdminChannelGrayList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminNewsList(pageNo) {
	var queryData = $("#admin_news_choose_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}
	$.ajax({
		url : path + "/admin/news/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminAccountList(pageNo) {
	var queryData = $("#admin_account_choose_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}
	$.ajax({
		url : path + "/admin/user/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deleteAccountById(userId) {
	$.ajax({
		url : path + "/admin/user/delete/" + userId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除帐号成功", {
					icon : 1
				});
				queryAdminAccountList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminPostList(pageNo) {
	var queryData = $("#admin_post_choose_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}
	$.ajax({
		url : path + "/admin/post/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deleteActivityById(postId) {
	$.ajax({
		url : path + "/admin/activity/delete/" + postId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除活动成功", {
					icon : 1
				});
				queryAdminPostList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deleteDishonestyById(postId) {
	$.ajax({
		url : path + "/admin/dishonesty/delete/" + postId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除失信记录成功", {
					icon : 1
				});
				queryAdminPostList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deleteChannelById(postId) {
	$.ajax({
		url : path + "/admin/channel/delete/" + postId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除渠道成功", {
					icon : 1
				});
				queryAdminPostList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deletePromotionById(postId) {
	$.ajax({
		url : path + "/admin/promotion/delete/" + postId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除引流需求成功", {
					icon : 1
				});
				queryAdminPostList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminDiscussList(pageNo) {
	var queryData = $("#admin_discuss_choose_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}
	$.ajax({
		url : path + "/admin/discuss/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deleteDiscussById(discussId) {
	$.ajax({
		url : path + "/admin/discuss/delete/" + discussId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除评论成功", {
					icon : 1
				});
				queryAdminDiscussList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminBannerList(pageNo) {
	$.ajax({
		url : path + "/admin/banner/list",
		type : "get",
		dataType : "html",
		data : {
			pageNo : pageNo
		},
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function queryAdminSensitiveWordList(pageNo) {
	var queryData = $("#admin_sensitiveWord_choose_form").serialize();

	if (queryData == null || queryData == "") {
		queryData = "pageNo=" + pageNo;
	} else {
		queryData = queryData + "&pageNo=" + pageNo;
	}

	$.ajax({
		url : path + "/admin/sensitiveWord/list",
		type : "get",
		dataType : "html",
		data : queryData,
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function toUpdateSensitiveWord(wordId) {
	$.ajax({
		url : path + "/admin/sensitiveWord/toUpdate/" + wordId,
		type : "get",
		dataType : "html",
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function toInsetSensitiveWord() {
	$.ajax({
		url : path + "/admin/sensitiveWord/toInsert",
		type : "get",
		dataType : "html",
		success : function(data) {
			$("#admin_list_div").html(data);
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function deleteSensitiveWordById(wordId) {
	$.ajax({
		url : path + "/admin/sensitiveWord/delete/" + wordId,
		type : "post",
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("删除敏感词成功", {
					icon : 1
				});
				queryAdminSensitiveWordList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function updateSensitiveWord() {
	$.ajax({
		url : path + "/admin/sensitiveWord/update",
		type : "post",
		data : $("#sensitiveWord_update_form").serialize(),
		dataType : "json",
		success : function(data) {
			if (data.result) {
				layer.msg("修改或新增敏感词成功", {
					icon : 1
				});
				queryAdminSensitiveWordList(1);
			} else {
				layer.msg(data.message, {
					icon : 2
				});
				;
			}
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}

function checkSensitiveWord() {
	$.ajax({
		url : path + "/admin/sensitiveWord/check",
		type : "post",
		data : $("#sensitiveWord_check_form").serialize(),
		dataType : "json",
		success : function(data) {
			layer.msg(data.message, {
				icon : 2
			});
		},
		error : function() {
			layer.msg("服务器网络繁忙", {
				icon : 2
			});
		}
	});
}
